/*
** escaping2.c for minishell2 in /home/guina_b/
** 
** Made by benoit guina
** Login   <guina_b@epitech.net>
** 
** Started on  Fri Jan 01 00:00:00 2010 benoit guina
** Last update Fri Jan 01 00:00:00 2010 benoit guina
*/

#include <string.h>
#include "escaping.h"

void escaping_strip(char *s)
{
  int i;

  i = strlen(s);
  while (--i >= 0)
    if (is_escaping(s, i))
      strcpy(s + i, s + i + 1);
}

char *escaping_strtok(char **s, const char *delim)
{
  char *start;
  int delim_l;
  int i;

  if (!*s)
    return (0);
  delim_l = strlen(delim);
  start = *s;
  i = -1;
  while ((*s)[++i] && (is_escaped(*s, i) != ESCAPING_NONE ||
                       strncmp(*s + i, delim, delim_l)));
  *s += i;
  if (**s)
  {
    memset(*s, 0, delim_l);
    *s += delim_l;
  }
  else
    *s = 0;
  return (start);
}
